/*$(document.body).css({  
            "overflow-y": "hidden"  
        });*/
var baseUrl = "/apistore/";
var serviceFile;
var functionFile;
var examplesFile;
var examples = [];
var errcodes = [];
var functions = [];
/****服务实体主*****/
var service_Header = [];
/****产品功能*****/
var service_Function = [];
/****API文档*****/
var service_Api = [];
/****错误参照*****/
var service_ErrorCode = [];
/****示例代码*****/
var service_Examples = [];
/****参数*****/
var parameters = [];
var serviceHead;

service_Parameter1={"id":"","serviceCode":"","paramName":"","dataType":"","isMust":"","remark":"","paramType":""};

service_Parameter={"id":"","serviceCode":"","paramName":"","dataType":"","isMust":"","remark":"","paramType":""};

service_Examples={"id":"","serviceCode":"","language":"","title":"","updateTime":"","examplesUrl":"","author":""};

service_ErrorCode={"id":"","serviceCode":"","errorCode":"","remark":""};

service_Api={"id":"","serviceCode":"","interfaceUrl":"","requestType":"","returnFormat":"",
				"requestExamples":"","interfaceRemark":"","testAddress":"","returnExamples":""};

service_Function ={"id":"","serviceCode":"","serviceIntroduce":"","serviceExamples":""};

functions.push(service_Function);

service_Header={"id":"","serviceCode":"","serviceName":"","categoryCode":"",
					"serviceImage":"","shortDesc":"","rankLabel":"","isGuarantee":"",
					"guaranteeAmount":"","releaseCode":"","releaseName":"","releaseTime":"",
					"auditType":"","auditor":"","auditTime":"","updateTime":"",
					"technicalSupport":"","contactNumber":"","fileName":"","fileUrl":"",
					"serviceQq":"","serviceWechat":"","hotspotSort":"","auditOpinion":"",
					"serviceState":"","serviceFunction":functions,"serviceErrorCode":errcodes,
					"serviceExamples":examples,"serviceApi":service_Api,"serviceParameter":parameters};



$(function() {
	
	Init();
	getAllcategory();
	if(tag==2){
		InitProduct();
	}
});

function Init(){
	/*$("#api_list").css("display","none");*/
	$("#api_function").css("display","none");
	$("#api_file").css("display","none");
	$("#api_errorcode").css("display","none");
	$("#api_examples").css("display","none");
	$("#a_1").css("background-color","#6766FF");
	$("#a_2").css("border-left-color","#6766FF");
	
}

function InitProduct(){
	serviceHead = header;
	$("input[name='service_name']").attr("value",serviceHead.serviceName);
	$("select[name='category_code']").find("option[val="+serviceHead.categoryCode+"]").attr("selected",true);
	$("input[name='short_desc']").attr("value",serviceHead.shortDesc);
	$("input[name='service_iamge']").attr("value",serviceHead.serviceImage);
    document.getElementById('img').src=baseUrl+"localImg/"+serviceHead.serviceImage;  
    $("#tu").show();
}

function getAllcategory(){
	var cate = $("select[name='category_code']");
	$.ajax({
		type: "POST",
	    url:baseUrl+"/categoryControler/selectAllcategory",
        contentType: "application/json",
	    success: function(result){
			if(result!=null){
				cate.empty(); 
				for(var i=0;i<result.length;i++){
					// 实际的应用中，这里的option一般都是用循环生成多个了 
					var option = $("<option>").val(result[i].categoryCode).text(result[i].categoryName); 
					cate.append(option); 
				}
			}
		}
	});
}

function calcel(){
	window.location.href=baseUrl+"serviceIndex?";
}
/********获取文件名称**********/
function getFileName(o){
    var pos=o.lastIndexOf("\\");
    return o.substring(pos+1);  
}
function nextPage(obj){
	if(obj==1){
		/*产品接入*/
		$("#api_list").css("display","block");
		$("#api_function").css("display","none");
		$("#a_1").css("background-color","#6766FF");
		$("#a_2").css("border-left-color","#6766FF");
		
		$("#b_1").css("border-top-color","#CCCCCC");
		$("#b_1").css("border-bottom-color","#CCCCCC");
		$("#b_2").css("background-color","#CCCCCC");
		$("#b_3").css("border-left-color","#CCCCCC");
	}else if(obj==2){
		var file=document.getElementById('YYZZFBSMJ').files[0];//获取文件流
		//serviceFile.append('file', file);
		service_Header.categoryCode = $("select[name='category_code']").val();
		service_Header.serviceName = $("input[name='service_name']").val();
		//service_Header.serviceImage = getFileName($("input[name='service_image']").val());
		service_Header.shortDesc = $("input[name='short_desc']").val();
		serviceFile = file;
		
		if(tag==2){
			functions = serviceHead.serviceFunction;
			service_Header.serviceImage = serviceHead.serviceImage;
			if(functions!=null){
				$("textarea[name='service_introduce']").attr("value",functions[0].serviceIntroduce);
				$("textarea[name='service_introduce']").text(functions[0].serviceIntroduce);
				service_Function.serviceExamples = functions[0].serviceExamples;
				document.getElementById('img1').src=baseUrl+"localImg/"+functions[0].serviceExamples;  
				$("#tu1").show();
			}
			
		}
		
		
		
		/*产品功能*/
		$("#api_list").css("display","none");
		$("#api_function").css("display","block");
		$("#api_file").css("display","none");
		$("#b_1").css("border-top-color","#6766FF");
		$("#b_1").css("border-bottom-color","#6766FF");
		$("#b_2").css("background-color","#6766FF");
		$("#b_3").css("border-left-color","#6766FF");
		
		$("#c_1").css("border-top-color","#CCCCCC");
		$("#c_1").css("border-bottom-color","#CCCCCC");
		$("#c_2").css("background-color","#CCCCCC");
		$("#c_3").css("border-left-color","#CCCCCC");
	}else if(obj==3){
		
		service_Function.serviceIntroduce = $("textarea[name='service_introduce']").val();
		//service_Function.serviceExamples = getFileName($("input[name='service_examples']").val());
		
		functionFile=document.getElementById('YYZZFBSMJ1').files[0];//获取文件流
		
		if(tag==2){
			var Api = serviceHead.serviceApi;
			if(Api!=null){
				$("input[name='interface_url']").attr("value",Api.interfaceUrl);
				$("input[name='return_format']").attr("value",Api.returnFormat);
				$("input[name='request_type']").attr("value",Api.requestType);
				$("input[name='request_Examples']").attr("value",Api.requestExamples);
				$("input[name='test_address']").attr("value",Api.testAddress); 
				$("textarea[name='interface_remark']").attr("value",Api.interfaceRemark);
				$("textarea[name='interface_remark']").text(Api.interfaceRemark);
				$("textarea[name='return_examples']").attr("value",Api.returnExamples);
				$("textarea[name='return_examples']").text(Api.returnExamples);
			}
			var params = serviceHead.serviceParameter;
			if(params!=null){
				$("#main_content_lists").html("");
				$("#main_content_lists1").html("");
				for (var i = 0; i < params.length; i++) {
					if(params[i].paramType==1){
						var attrHtml = "";
						attrHtml+="<div class=\"main_content_list\" name=\"main_content_list\"><div class=\"main_content_list_space\"></div>";
						attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"param_name\" value=\""+params[i].paramName+"\"/></div>";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"is_must\" value=\""+params[i].isMust+"\"/></div>";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"data_type\" value=\""+params[i].dataType+"\"/></div>";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"param_remark\" value=\""+params[i].remark+"\"/></div>";
						attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
						attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
						$("#main_content_lists").append(attrHtml);
					}else{
						var attrHtml = "";
						attrHtml+="<div class=\"main_content_list\" name=\"main_content_list1\"><div class=\"main_content_list_space\"></div>";
						attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_param_name\" value=\""+params[i].paramName+"\"/></div>";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_data_type\" value=\""+params[i].dataType+"\"/></div>";
						attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_param_remark\" value=\""+params[i].remark+"\"/></div>";
						attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
						attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
						$("#main_content_lists1").append(attrHtml);
					}
				}
			}
		}
		
		/*API文档*/
		$("#api_function").css("display","none");
		$("#api_file").css("display","block");
		$("#api_errorcode").css("display","none");
		$("#c_1").css("border-top-color","#6766FF");
		$("#c_1").css("border-bottom-color","#6766FF");
		$("#c_2").css("background-color","#6766FF");
		$("#c_3").css("border-left-color","#6766FF");
		
		$("#d_1").css("border-top-color","#CCCCCC");
		$("#d_1").css("border-bottom-color","#CCCCCC");
		$("#d_2").css("background-color","#CCCCCC");
		$("#d_3").css("border-left-color","#CCCCCC");
	}else if(obj==4){
		
		service_Api.interfaceUrl = $("input[name='interface_url']").val();
		service_Api.returnFormat = $("input[name='return_format']").val();
		service_Api.requestType = $("input[name='request_type']").val();
		service_Api.requestExamples = $("input[name='request_Examples']").val();
		service_Api.testAddress = $("input[name='test_address']").val(); 
		service_Api.interfaceRemark = $("textarea[name='interface_remark']").val(); 
		service_Api.returnExamples = $("textarea[name='return_examples']").val(); 
		
		$("div[name='main_content_list']").each(function(j,item){
		      // 你要实现的业务逻辑
			var param_name = $(item).find("input[name='param_name']").val();
			var isMust = $(item).find("input[name='is_must']").val();
			var dataType = $(item).find("input[name='data_type']").val();
			var remark = $(item).find("input[name='param_remark']").val();
			var parameter={"id":"","serviceCode":"","paramName":"","dataType":"","isMust":"","remark":"","paramType":""};
			parameter.paramName = param_name;
			parameter.isMust = isMust;
			parameter.dataType = dataType;
			parameter.remark = remark;
			parameter.paramType = "1";
			if(param_name!=null && param_name!=""){
				parameters.push(parameter);
			}
		    console.log(param_name);  //输出input 中的 value 值到控制台
		});
		
		$("div[name='main_content_list1']").each(function(j,item){
		      // 你要实现的业务逻辑
			var param_name = $(item).find("input[name='r_param_name']").val();
			var dataType = $(item).find("input[name='r_data_type']").val();
			var remark = $(item).find("input[name='r_param_remark']").val();
			var parameter={"id":"","serviceCode":"","paramName":"","dataType":"","isMust":"","remark":"","paramType":""};
			parameter.paramName = param_name;
			parameter.dataType = dataType;
			parameter.remark = remark;
			parameter.paramType = "2";
		    if(param_name!=null && param_name!=""){
				parameters.push(parameter);
			}
		    console.log(param_name);  //输出input 中的 value 值到控制台
		});
		
		service_Header.serviceParameter = parameters;
		
		/*错误参照码*/
		$("#api_file").css("display","none");
		$("#api_errorcode").css("display","block");
		$("#api_examples").css("display","none");
		$("#d_1").css("border-top-color","#6766FF");
		$("#d_1").css("border-bottom-color","#6766FF");
		$("#d_2").css("background-color","#6766FF");
		$("#d_3").css("border-left-color","#6766FF");
		
		$("#e_1").css("border-top-color","#CCCCCC");
		$("#e_1").css("border-bottom-color","#CCCCCC");
		$("#e_2").css("background-color","#CCCCCC");
		
		if(tag==2){
			var errors = serviceHead.serviceErrorCode;
			if(errors!=null){
				$("#content_error_attrs").html("");
				for (var i = 0; i < errors.length; i++) {
					var attrHtml = "";
					attrHtml+="<div class=\"content_error_attr\" name=\"main_content_list2\"><div class=\"main_content_list_space\"></div><div class=\"content_error_space\"></div>";
					attrHtml+="<div class=\"content_error_div\"><div class=\"content_error_div_lists\">";
					attrHtml+="<div class=\"content_error_div_title\">错误码：</div>";
					attrHtml+="<div class=\"content_error_div_code\"><input type=\"text\" class=\"content_error_input\" name=\"error_code\" value=\""+errors[i].errorCode+"\"/></div>";
					attrHtml+="<div class=\"main_bottom_space\"></div></div><div class=\"content_error_div_lists\">";
					attrHtml+="<div class=\"content_error_div_title\">说明：</div>";
					attrHtml+="<div class=\"content_error_div_desc\"><input type=\"text\" class=\"content_error_input1\" name=\"error_remark\" value=\""+errors[i].remark+"\"/></div>";
					attrHtml+="<div class=\"main_bottom_space\"></div></div></div>";
					attrHtml+="<div class=\"attr_delete1\" onclick=\"attr_delete1(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
					attrHtml+="<div class=\"main_content_list_space\"></div></div>";
					$("#content_error_attrs").append(attrHtml);
				}
			}
		}
	}else if(obj==5){
		
		$("div[name='main_content_list2']").each(function(j,item){
		      // 你要实现的业务逻辑
			var errorCode = $(item).find("input[name='error_code']").val();
			var remark = $(item).find("input[name='error_remark']").val();
			var errorCodes={"id":"","serviceCode":"","errorCode":"","remark":""};
			errorCodes.errorCode = errorCode;
			errorCodes.remark = remark;
			if(errorCode!=null && errorCode!=""){
				errcodes.push(errorCodes);
			}
		    console.log(errorCode);  //输出input 中的 value 值到控制台
		});
		
		service_Header.serviceErrorCode = errcodes;
		/*示例代码*/
		$("#api_errorcode").css("display","none");
		$("#api_examples").css("display","block");
		$("#e_1").css("border-top-color","#6766FF");
		$("#e_1").css("border-bottom-color","#6766FF");
		$("#e_2").css("background-color","#6766FF");
		
		if(tag==2){
			var exams = serviceHead.serviceExamples;
			if(exams!=null){
				$("#main_content_lists2").html("");
				for (var i = 0; i < exams.length; i++) {
					var attrHtml = "";
					attrHtml+="<div class=\"main_content_list\" name=\"main_content_list3\"><div class=\"main_content_list_space\"></div>";
					attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
					attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"language\" value=\""+exams[i].language+"\"/></div>";
					attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"examples_url\" value=\""+exams[i].examplesUrl+"\"/></div>";
					attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"author\" value=\""+exams[i].author+"\"/></div>";
					attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"update_time\" value=\""+exams[i].updateTime+"\"/></div>";
					attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
					attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
					$("#main_content_lists2").append(attrHtml);
				}
			}
		}
	}
}

function upload(){
	document.getElementById("YYZZFBSMJ").click();
}
function upload1(){
	document.getElementById("YYZZFBSMJ1").click();
}

function fileType(obj){
    var fileType=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
    if(fileType != '.gif' && fileType != '.png' && fileType != '.jpg' && fileType != '.jpeg'){
        $(obj).tips({
            side:3,
            msg:'请上传图片格式的文件',
            bg:'#AE81FF',
            time:3
        });
        $(obj).val('');
    }else{
         var reader = new FileReader();
         reader.readAsDataURL(obj.files[0]);
         reader.onload = function (e) { 
            $("#img").attr("src",this.result);
         }
         service_Header.serviceImage = getFileName(obj.value);
         uploadFile(obj.id);
         $("#tu").show();
    }
}

function uploadFile(fileId){
	$.ajaxFileUpload({
		type:"post",
		url:baseUrl+"/service/uploadFile",
		dataType:"json",
		async:false,
		secureuri:false,
		fileElementId:fileId,
		success:function(result){
			alert(success);
		}
		
		
	});
}

function fileType1(obj){
    var fileType=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
    if(fileType != '.gif' && fileType != '.png' && fileType != '.jpg' && fileType != '.jpeg'){
        $(obj).tips({
            side:3,
            msg:'请上传图片格式的文件',
            bg:'#AE81FF',
            time:3
        });
        $(obj).val('');
    }else{
         var reader = new FileReader();
         reader.readAsDataURL(obj.files[0]);
         reader.onload = function (e) { 
            $("#img1").attr("src",this.result);
         }
         service_Function.serviceExamples = getFileName(obj.value);
         uploadFile(obj.id);
         $("#tu1").show();
    }
}


function attr_delete(obj){
	var attrs = $(obj).parent().parent().parent();
	attrs.html("");
}
function attr_delete1(obj){
	var attrs = $(obj).parent();
	attrs.html("");
}
function attr_add(){
	var attrHtml = "";
	attrHtml+="<div class=\"main_content_list\" name=\"main_content_list\"><div class=\"main_content_list_space\"></div>";
	attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"param_name\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"is_must\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"data_type\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"param_remark\"/></div>";
	attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
	attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
	$("#main_content_lists").append(attrHtml);
	
}


function attr_add1(){
	var attrHtml = "";
	attrHtml+="<div class=\"main_content_list\" name=\"main_content_list1\"><div class=\"main_content_list_space\"></div>";
	attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_param_name\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_data_type\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"r_param_remark\"/></div>";
	attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
	attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
	$("#main_content_lists1").append(attrHtml);
	
}

function attr_add2(){
	var attrHtml = "";
	attrHtml+="<div class=\"content_error_attr\" name=\"main_content_list2\"><div class=\"main_content_list_space\"></div><div class=\"content_error_space\"></div>";
	attrHtml+="<div class=\"content_error_div\"><div class=\"content_error_div_lists\">";
	attrHtml+="<div class=\"content_error_div_title\">错误码：</div>";
	attrHtml+="<div class=\"content_error_div_code\"><input type=\"text\" class=\"content_error_input\" name=\"error_code\"/></div>";
	attrHtml+="<div class=\"main_bottom_space\"></div></div><div class=\"content_error_div_lists\">";
	attrHtml+="<div class=\"content_error_div_title\">说明：</div>";
	attrHtml+="<div class=\"content_error_div_desc\"><input type=\"text\" class=\"content_error_input1\" name=\"error_remark\"/></div>";
	attrHtml+="<div class=\"main_bottom_space\"></div></div></div>";
	attrHtml+="<div class=\"attr_delete1\" onclick=\"attr_delete1(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
	attrHtml+="<div class=\"main_content_list_space\"></div></div>";
	$("#content_error_attrs").append(attrHtml);
	
}

function attr_add3(){
	var attrHtml = "";
	attrHtml+="<div class=\"main_content_list\" name=\"main_content_list3\"><div class=\"main_content_list_space\"></div>";
	attrHtml+="<div class=\"content_lists\"><div class=\"main_content_attr\"></div><div class=\"attr_list_values\">";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"language\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"examples_url\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"text\" class=\"attr_values_input\" name=\"author\"/></div>";
	attrHtml+="<div class=\"attr_values\"><input type=\"date\" class=\"attr_values_input\" name=\"update_time\"/></div>";
	attrHtml+="<div class=\"attr_delete\" onclick=\"attr_delete(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
	attrHtml+="</div></div><div class=\"main_content_list_space\"></div></div>";
	$("#main_content_lists2").append(attrHtml);
	
}

function attr_add4(){
	var attrHtml = "";
	attrHtml+="<div class=\"content_error_attr\" name=\"main_content_list4\"><div class=\"main_content_list_space\"></div><div class=\"content_error_space\"></div>";
	attrHtml+="<div class=\"content_error_div\"><div class=\"content_error_div_lists\">";
	attrHtml+="<div class=\"content_error_div_title\">错误码：</div>";
	attrHtml+="<div class=\"content_error_div_code\"><input type=\"text\" class=\"content_error_input\"/></div>";
	attrHtml+="<div class=\"main_bottom_space\"></div></div><div class=\"content_error_div_lists\">";
	attrHtml+="<div class=\"content_error_div_title\">说明：</div>";
	attrHtml+="<div class=\"content_error_div_desc\"><input type=\"text\" class=\"content_error_input1\"/></div>";
	attrHtml+="<div class=\"main_bottom_space\"></div></div></div>";
	attrHtml+="<div class=\"attr_delete1\" onclick=\"attr_delete1(this)\"><i class=\"fa fa-minus-circle\"></i></div>";
	attrHtml+="<div class=\"main_content_list_space\"></div></div>";
	$("#content_error_attrs1").append(attrHtml);
	
}

//提交按钮
$("#btn_savecontext").click(function(){
	
	service_Examples.language = $("input[name='language']").val();
	service_Examples.examplesUrl = $("input[name='examples_url']").val();
	service_Examples.author = $("input[name='author']").val();
	service_Examples.updateTime =  $("input[name='update_time']").val();
	
	service_Header.serviceState = "1";
	
	$("div[name='main_content_list3']").each(function(j,item){
	      // 你要实现的业务逻辑
		var language = $(item).find("input[name='language']").val();
		var examplesUrl = $(item).find("input[name='examples_url']").val();
		var author = $(item).find("input[name='author']").val();
		var updateTime = $(item).find("input[name='update_time']").val();
		var example={"id":"","serviceCode":"","language":"","title":"","updateTime":"","examplesUrl":"","author":""};
		example.language = language;
		example.examplesUrl = examplesUrl;
		example.author = author;
		example.updateTime = updateTime;
		if(language!=null && language!=""){
			examples.push(example);
		}
	    console.log(language);  //输出input 中的 value 值到控制台
	});
	
	service_Header.serviceExamples = examples;
	
	
	/*var  objname = $("#input_resname").val();
	var  objtype = $("#input_restype option:selected").val();
	var  servicetype = $("#input_servicetype option:selected").val();
	var  objserverurl = $("#input_resurl").val();
	var  objaccesstoken = $("#input_restoken").val();
	var  servicename = $("#input_servicename").val();
	if(objname ==null || objname ==""){
		ShowTip_Warn('响应对象名称不能为空!');
		return false;
	}*/
	if(tag==2){
		service_Header.serviceCode=serviceHead.serviceCode;
		$.ajax({
			type: "POST",
		    url:baseUrl+"/service/updateApiService",
	        contentType: "application/json",
		    data: JSON.stringify(service_Header),
		    success: function(r){
				if(r.code == 0){
					alert('操作成功', function(){
						
					});
				}else{
					alert(r.msg);
				}
			}
		});
	}else{
		$.ajax({
			type: "POST",
		    url:baseUrl+"/service/addApiService",
	        contentType: "application/json",
		    data: JSON.stringify(service_Header),
		    success: function(r){
				if(r.code == 0){
					alert('操作成功', function(){
						
					});
				}else{
					alert(r.msg);
				}
			}
		});
	}
	//window.location.href=baseUrl+"#";
	
})

